package com.ruoyi.market.enums;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SpecialEnum {

    public static void main(String[] args) {
        System.out.println(JSON.toJSONString(dataList));
    }

    public static List<BaseTypeInfo> dataList = new ArrayList<>();

    static {
        dataList.add(
                BaseTypeInfo.loanAmount
        );
        dataList.add(
                BaseTypeInfo.zhimaScore
        );
        dataList.add(
                BaseTypeInfo.gjj
        );
        dataList.add(
                BaseTypeInfo.house
        );
        dataList.add(
                BaseTypeInfo.car
        );
        dataList.add(
                BaseTypeInfo.insurance
        );
        dataList.add(
                BaseTypeInfo.socialInsurance
        );
    }


    @Data
    public static class BaseTypeInfo{
        private  String name;
        private  String value;
        private  List<Map<String, String>> itemList;

        public static BaseTypeInfo loanAmount = BaseTypeInfo.build(LoanAmount.baseName, LoanAmount.baseValue, LoanAmount.getDataMap());
        public static BaseTypeInfo zhimaScore = BaseTypeInfo.build(ZhimaScore.baseName, ZhimaScore.baseValue, ZhimaScore.getDataMap());
        public static BaseTypeInfo huaBei = BaseTypeInfo.build(HuaBei.baseName, HuaBei.baseValue, HuaBei.getDataMap());
        public static BaseTypeInfo baiTiao = BaseTypeInfo.build(BaiTiao.baseName, BaiTiao.baseValue, BaiTiao.getDataMap());

        public static BaseTypeInfo gjj = BaseTypeInfo.build(Gjj.baseName, Gjj.baseValue, Gjj.getDataMap());
        public static BaseTypeInfo house = BaseTypeInfo.build(House.baseName, House.baseValue, House.getDataMap());
        public static BaseTypeInfo car = BaseTypeInfo.build(Car.baseName, Car.baseValue, Car.getDataMap());
        public static BaseTypeInfo insurance = BaseTypeInfo.build(Insurance.baseName, Insurance.baseValue, Insurance.getDataMap());
        public static BaseTypeInfo socialInsurance = BaseTypeInfo.build(SocialInsurance.baseName, SocialInsurance.baseValue, SocialInsurance.getDataMap());

        public static BaseTypeInfo build(String name, String value, List<Map<String, String>> itemList){
            BaseTypeInfo baseTypeInfo = new BaseTypeInfo();
            baseTypeInfo.setName(name);
            baseTypeInfo.setValue(value);
            baseTypeInfo.setItemList(itemList);
            return baseTypeInfo;
        }
    }

    @Getter
    public enum LoanAmount{

        la001( "1-3万", "la001"),
        la002( "3-5万", "la002"),
        la003( "5万以上", "la003"),
        la004( "10-20万", "la004"),
        la005( "20万以上", "la005"),
        ;

        public static String baseName = "贷款额度";
        public static String baseValue = "loanAmont";

        String value;
        String name;

        LoanAmount(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static String getNameByValue(String value){
            for (LoanAmount loanAmount: values()){
                if (StringUtils.equals(value, loanAmount.getValue())){
                    return loanAmount.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (LoanAmount item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum HuaBei{

        hb001( "无", "hb001"),
        hb002( "1-3万", "hb002"),
        hb003( "3万-5万", "hb003"),
        hb004( "5万以上", "hb004"),
        ;

        public static String baseName = "花呗";
        public static String baseValue = "huabei";

        String value;
        String name;


        HuaBei(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (HuaBei item: values()){
                if (StringUtils.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (HuaBei item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }



    @Getter
    public enum BaiTiao{

        bt001( "无", "bt001"),
        bt002( "1-3万", "bt002"),
        bt003( "3万-5万", "bt003"),
        bt004( "5万以上", "bt004"),
        ;

        public static String baseName = "白条";
        public static String baseValue = "baitiao";

        String value;
        String name;


        BaiTiao(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (BaiTiao item: values()){
                if (StringUtils.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (BaiTiao item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum ZhimaScore{

        zm001( "无", "zm001"),
        zm002( "0-600", "zm002"),
        zm003( "600-650", "zm003"),
        zm004( "650-700", "zm004"),
        zm005( "700以上", "zm005"),
        ;

        public static String baseName = "芝麻分数";
        public static String baseValue = "zhimaScore";

        String value;
        String name;
        

        ZhimaScore(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (ZhimaScore zhimaScore: values()){
                if (StringUtils.equals(value, zhimaScore.getValue())){
                    return zhimaScore.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (ZhimaScore item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

        public static List<Map<String, Object>> getDataMapListCheckd(String itemListStr){

            List<String> itemList = new ArrayList<>();
            if (StrUtil.isNotEmpty(itemListStr)){
                itemList = JSON.parseArray(itemListStr, String.class);
            }

            List<Map<String, Object>> resultList = new ArrayList<>();
            for (ZhimaScore item: values()){
                Map<String, Object> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                if (CollUtil.isNotEmpty(itemList) && itemList.contains(item.getValue())){
                    map.put("checked", true);
                }else{
                    map.put("checked", false);
                }
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Yuqi{

        yq001("有逾期", "yq001"),
        yq002("无逾期", "yq002"),
        ;

        public static String baseName = "有逾期";
        public static String baseValue = "yuqi";

        String value;
        String name;


        Yuqi(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (Yuqi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Yuqi item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }

    }

    @Getter
    public enum Gjj{

        gjj001("无公积金", "gjj001"),
        gjj002("有公积金", "gjj002"),
        gjj003("6个月以上", "gjj003"),
        gjj004("6个月以下", "gjj004"),
        ;

        public static String baseName = "公积金";
        public static String baseValue = "gjj";

        String value;
        String name;
        

        Gjj(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Gjj gjj: values()){
                if (StringUtils.equals(value, gjj.getValue())){
                    return gjj.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Gjj item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }


    @Getter
    public enum House{

        hu001( "无房", "hu001"),
        hu002( "有房", "hu002"),
        ;

        public static String baseName = "房产情况";
        public static String baseValue = "house";

        String value;
        String name;
        

        House(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (House house: values()){
                if (StringUtils.equals(value, house.getValue())){
                    return house.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (House item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Car{

        car001("无车", "car001"),
        car002("有车", "car002"),
        ;

        public static String baseName = "车辆情况";
        public static String baseValue = "car";

        String value;
        String name;
        

        Car(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Car car: values()){
                if (StringUtils.equals(value, car.getValue())){
                    return car.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Car item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum Insurance{

        in001( "无保单", "in001"),
        in002( "有保单", "in002"),
        in003( "2年以上", "in003"),
        in004( "2年以下", "in004"),
        ;

        public static String baseName = "保单情况";
        public static String baseValue = "insurance";

        String value;
        String name;
        

        Insurance(String name, String value){
            this.value = value;
            this.name = name;
            
        }

        public static String getNameByValue(String value){
            for (Insurance insurance: values()){
                if (StringUtils.equals(value, insurance.getValue())){
                    return insurance.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (Insurance item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum SocialInsurance{

        si001( "无社保", "si001"),
        si002( "有社保", "si002"),
        si003( "6个月以上", "si003"),
        si004( "6个月以下", "si004"),
        ;

        public static String baseName = "有社保";
        public static String baseValue = "socialInsurance";

        String value;
        String name;


        SocialInsurance(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (SocialInsurance item: values()){
                if (StringUtils.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (SocialInsurance item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum EnterpriseOwner{

        eo001( "非企业主", "eo001"),
        eo002( "企业主", "eo002"),
        ;

        public static String baseName = "有社保";
        public static String baseValue = "enterpriseOwner";

        String value;
        String name;


        EnterpriseOwner(String name, String value){
            this.value = value;
            this.name = name;

        }

        public static String getNameByValue(String value){
            for (EnterpriseOwner item: values()){
                if (StringUtils.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }

        public static List<Map<String, String>> getDataMap(){
            List<Map<String, String>> resultList = new ArrayList<>();
            for (EnterpriseOwner item: values()){
                Map<String, String> map = new HashMap<>();
                map.put("name", item.getName());
                map.put("value", item.getValue());
                resultList.add(map);
            }
            return resultList;
        }
    }

    @Getter
    public enum XueLi{

        xl001("初中及以下", "xl001"),
        xl002("高中", "xl002"),
        xl003("中专", "xl003"),
        xl004("大专", "xl004"),
        xl005("本科及以上", "xl005"),
        ;

        String value;
        String name;

        XueLi(String name, String value){
            this.value = value;
            this.name = name;
        }

        public static XueLi getEntryByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item;
                }
            }
            return xl002;
        }

        public static String getNameByValue(String value){
            for (XueLi item: values()){
                if (StrUtil.equals(value, item.getValue())){
                    return item.getName();
                }
            }
            return null;
        }
    }

}
